import type { IQuery, IResponse, TableResponse } from '@/api/config/types';
import type { SYS_THEME } from '@/enum/system';
import axios from 'axios';

export interface IStore {
  id: string;
  parentId: string;
  storeName: string;
  storeManager: string;
  storeNo: string;
  telephone: string;
  status: string;
  renew: string;
  expire: null;
  details: string;
  createTime: string;
  updateTime: string;
}
export interface PageForm {
  title: string;
  logo: string;
  theme: SYS_THEME;
}
const prefix = '/store/store';

// 查询门店列表
export const queryStore = () => axios.get<IResponse<IStore[]>>(`${prefix}/query`);
// 查询门店列表
export const listStore = (query: IQuery) => {
  return axios.get<TableResponse<IStore>>(`${prefix}/list`, { params: query });
};

// 删除门店
export const delStore = (id: Array<string>) => {
  return axios.delete(`${prefix}/${id.join(',')}`);
};

// 查询门店
export const editStore = (id: string | number) => {
  return axios.get<IResponse<IStore>>(`${prefix}/${id}`);
};

// 新增门店
export const addStore = (data: IStore) => {
  return axios.post(`${prefix}`, data);
};

// 修改门店
export const updateStore = (data: IStore) => {
  return axios.put(`${prefix}`, data);
};

// 修改附加信息
export const updateDetails = (data: any) => {
  return axios.post(`${prefix}/details`, data);
};

// 查询附加信息
export const getDetails = () => {
  return axios.get(`${prefix}/details`);
};

// 获取门店选项
export const fetchStoreOptions = () => {
  return axios.get('/store/store/options');
};
